package com.wishwall.persistence.managers;

import javax.persistence.Query;

import com.sun.servicetag.UnauthorizedAccessException;
import com.wishwall.beans.UserBean;
import com.wishwall.persistence.PersistenceContext;

/**
 * 
 * @author yavor.gologanov
 *
 */
public class UserManager extends AbstractBeanManager {

	/**
	 *
	 * @param persistenceContext
	 */
	public UserManager(PersistenceContext persistenceContext) {
		super(persistenceContext);
	}	
	
	/**
	 * 
	 * @param username
	 * @return
	 */
	public UserBean getUser(String username) {
		Query query = getEntityManager().createQuery("select u from UserBean u where u.username = :username");
		query.setParameter("username", username);
		return (UserBean) query.getSingleResult();
	}
	
	/**
	 * 
	 * @param userName
	 * @param resourceClassName
	 * @param resourceId
	 * @throws UnauthorizedAccessException
	 */
	public void checkResourcePermissions(String userName, Class<?> resourceClassName, Integer resourceId) throws UnauthorizedAccessException {
		
	}
	
}
